<!-- 
@name: 分享平台
-->
<template>
	<div id="share" class="page">
		<img class="shareImg" object-fit="fill" :src="dataList.sharePhoto"></img>
		<div class="rule">
			<div>活动规则：</div>
			<div>1.好友必须是农商银行用户，否则无法完成注册;</div>
			<div>2.每成功邀请一位好友可获得积分奖励。</div>
		</div>
		<div class="flex-row flex-center">
			<van-button type="info" class="button2" @click="shareTipClick(true)">分享好友</van-button>

		</div>
				<shareTip :show='shareTipShow' @shareTipHiden="shareTipClick(false)"></shareTip>

	</div>
</template>
<script>
import shareTip from '@/components/global/shareTip.vue'

export default {
	name: 'app',
	components: {shareTip},
	data() {
		return {
			dataList: {},
			shareTipShow: false,
		};
	},

	created() {
		this.getData();
		// this.genPoster_share();
	},
	methods: {
			shareTipClick(b){
			this.shareTipShow = b
		},
		genPoster_share() {
			// if (this.shareImg) {
			// 	// 已生成海报
			// 	this.shareShow = true;
			// 	return;
			// }
			var params = {
				objPkey: 0,
				type: 'INVITE_REGISTER',
			};
			// this.loadingShow = true;
			this.$myApi.genPoster_share(params).then((res) => {
				if (res.code == 0) {
					this.dataList.sharePhoto= res.result;
					
				}
			});
		},
		shareClick() {
			this.$notify({
				type: 'primary',
				message: '请点击右上角 通过发送给朋友邀请',
			});
		},
		getData() {
			var params = {};
			this.$myApi['getConfig_index'](params).then((res) => {
				if (res.code == 0) {
					this.dataList = res.result;
					this.share();
				} else {
				}
			});
		},
		share() {
			var link =
				this.$store.state.shareUrl +
				'/share/shareRegister?pkey=' +
				this.$store.state.userinfo.pkey;
			var dataList = {
				title: 'WaWa搭子', // 分享标题
				desc: '分享好友注册获得积分', // 分享描述
				imgUrl: this.dataList.sharePhoto, // 分享图标
			};
			this.updateAppMessageShareData(dataList, link);
		},
		goHandle() {
			this.$router.push({
				path: '/BankingBusiness/handle',
				query: { item: JSON.stringify(this.dataList) },
			});
		},
		goDetail(pkey) {
			// console.log()
			this.$router.push({
				path: '/BankingBusiness/share',
				query: { pkey: pkey },
			});
		},
		sortChange(pkey) {
			this.searchData.sortType = pkey;
			this.clearSearch();
			this.finished = true;
			this.getData(true);
		},
		onLoad() {
			console.log('触底');
			this.getData();
		},
		onClick() {
			this.clearSearch();
			this.finished = true;
			this.getData(true);
		},
		getGtype_goods() {
			this.$myApi.getGtype_goods().then((res) => {
				if (res.code == 0) {
					var arr = [{ name: '全部', pkey: '' }, ...res.result];
					this.getGtypeList = arr;
				} else {
				}
			});
		},

		clearSearch() {
			this.likeList = [];
			this.searchData.page = 0;
			this.searchData.pagesize = 5;
			this.finished = false;
		},
		onSearch(e) {
			console.log(e);
			this.clearSearch();
			this.searchData.title = e;
			this.finished = true;
			this.getData(true);
		},
		onCancel() {},
	},
};
</script>
<style lang="less" scoped>
#share {
	padding-left: 0rem;
	padding-right: 0rem;
	min-height: 100vh;
	background-color: #fafafa;

	padding-bottom: 0;
	.rule {
		font-size: 0.24rem;
		font-family: PingFang SC;
		font-weight: 500;
		color: #8f5008;
		line-height: 0.36rem;
		background: #f8cf6d;
		padding: 0.23rem 0.49rem;
	}
	.button1 {
		border: none;
		background: #3d84ff;
		border-top-left-radius: 30px;
		border-bottom-left-radius: 30px;
		width: 40%;
		margin: 0.4rem 0;
		font-size: 0.32rem;
		padding: 0.3rem 0;
		height: auto;
	}
	.button2 {
		font-size: 0.32rem;
		margin: 0.4rem 0;
		width: 80%;
		border: none;
		background: #ffce17;
		color: #000;
		padding: 0.3rem 0;
		height: auto;
		border-radius: 30px;
	}
	.shareImg {
		width: 100%;
		height: auto;
		display: block;
	}
}
</style>
<style lang="less" scoped>
/deep/.van-search .van-cell {
	padding-top: 0.2rem;
	padding-bottom: 0.2rem;
	font-size: 0.28rem;
}
/deep/.van-tab {
	// flex: 0 1 auto;
	// width: 1rem;
	font-size: 0.3rem;
}
/deep/.van-tab--active {
	font-weight: bold;
	font-size: 0.32rem;
}
</style>